﻿#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <initializer_list>
using namespace std;

#include "mySet.h"
#include "myMap.h"

namespace hd
{
	void test1()
	{
		set<int> s;
		int data[] = { 5, 10, 100, 2, 5, 9, 2 };
		for (auto& e : data)
			s.insert(e);
		set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << ' ';
			++it;
		}
		cout << endl;
		/*auto rit = s.end();
		while (rit != s.begin())
		{
			rit--;
			cout << *rit << ' ';
		}
		cout << endl;
		rit = s.find(5);
		cout << *rit << endl;*/
	}
	void test2()
	{
		const set<int> s = { 1, 5, 10, 30 };
		set<int>::const_iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << ' ';
			++it;
		}
		cout << endl;

		auto rit = s.end();
		while (rit != s.begin())
		{
			rit--;
			cout << *rit << ' ';
		}
		cout << endl << *(s.find(30)) << endl;
	}
	void test3()
	{
		map<string, string> m;
		pair<string, string> p[] = { {"left", "左边"},{"right", "右边"},{"totoro", "龙猫"},{"dudu", "嘟嘟"} };
		for (auto& e : p)
			m.insert(e);
		auto it = m.begin();
		while (it != m.end())
		{
			cout << it->first << ':' << it->second << endl;
			it++;
		}
		cout << endl;
		map<string, string>::iterator rit = m.end();
		while (rit != m.begin())
		{
			--rit;
			cout << rit->first << ':' << rit->second << endl;
		}
		cout << endl;
		cout << m.find("left")->first << ':' << m.find("left")->second << endl;
	}
	void test4()
	{
		const map<string, string> m = { {"left", "左边"},{"right", "右边"},{"totoro", "龙猫"},{"dudu", "嘟嘟"} };
		auto it = m.begin();
		while (it != m.end())
		{
			cout << it->first << ':' << it->second << endl;
			it++;
		}
		cout << endl;
		map<string, string>::const_iterator rit = m.end();
		while (rit != m.begin())
		{
			--rit;
			cout << rit->first << ':' << rit->second << endl;
		}
		cout << endl;
		cout << m.find("left")->first << ':' << m.find("left")->second << endl;
	}
	void test5()
	{
		map<string, int> m;
		string word;
		while (cin >> word)
		{
			m[word]++;
		}
		for (auto& e : m)
			cout << e.first << ':' << e.second << endl;
	}
	void test6()
	{
		map<string, string> dict;
		dict.insert({ "hehe", "呵呵" });
		dict.insert({ "haha", "哈哈" });
		dict.insert({ "left", "左边" });
		//dict["left"] = "左";
		dict["totoro"];
		dict["totoro"] = "龙猫";
		for (auto& e : dict)
			cout << e.first << ':' << e.second << endl;
	}
}

int main()
{
	//hd::test1();
	//hd::test2();
	//hd::test3();
	//hd::test4();
	hd::test5();
	//hd::test6();
	return 0;
}